home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / IDE / SUBARTIC / RELEASE.ZIP / sub_arctic / constraints / std_constraint.java < prev    next >
Encoding:
Java Source  |  1996-10-04  |  4.8 KB  |  139 lines

  1.  
  2. package sub_arctic.constraints;
  3.  
  4. /**
  5.  * Base class for objects that represent standard lightweight constraints.  
  6.  * Here we store the integer encoding as well as the orientation of the 
  7.  * constraint and a reference to the constraint_impl object that understands
  8.  * the encoding.
  9.  *
  10.  * @author Scott Hudson
  11.  */
  12. public class std_constraint implements constraint {
  13.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  14.  
  15.   /** Encoding of constraint as an integer. */ 
  16.   protected int _encoding;
  17.  
  18.   /** Encoding of constraint as an integer. */ 
  19.   public int encoding() {return _encoding;}
  20.  
  21.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  22.  
  23.   /** The implementation object for this constraint. */
  24.   protected constraint_impl _impl;
  25.  
  26.   /** The implementation object for this constraint. */
  27.   public constraint_impl impl() {return _impl;}
  28.  
  29.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  30.  
  31.   /** Orientation of the constraint.  This is a bitset made up of any of:
  32.    *  std_encoding_consts.HORIZONTAL, std_encoding_consts.VERTICAL, and/or
  33.    *  std_encoding_consts.NOT_ORIENTED.
  34.    */
  35.   protected int _orientation;
  36.  
  37.   /** Orientation of the constraint.  This is a bitset made up of any of:
  38.    *  std_encoding_consts.HORIZONTAL, std_encoding_consts.VERTICAL, and/or
  39.    *  std_encoding_consts.NOT_ORIENTED.
  40.    */
  41.   public int orientation() {return _orientation;}
  42.  
  43.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  44.  
  45.   /** 
  46.    * Full constructor.<p>
  47.    *
  48.    * @param int             encode_val the encoding for this constraint.
  49.    * @param constraint_impl imp        the implementation object that 
  50.    *                                   understands the encoding above.
  51.    * @param int             orient     the orientation of the constraint (one 
  52.    *                                   or more bits from 
  53.    *                                   std_encoding_consts.HORIZONTAL, 
  54.    *                                   std_encoding_consts.VERTICAL, and/or 
  55.    *                                   std_encoding_consts.NOT_ORIENTED).
  56.    */
  57.   public std_constraint(int encode_val, constraint_impl imp, int orient)
  58.     {
  59.       _encoding = encode_val;
  60.       _impl = imp;
  61.       _orientation = orient;
  62.     }
  63.  
  64.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  65.  
  66.   /** 
  67.    * Constructor defaulting to the standard constraint implementation.<p> 
  68.    * 
  69.    * @param int             encode_val the encoding for this constraint.
  70.    * @param int             orient     the orientation of the constraint (one 
  71.    *                                   or more bits from 
  72.    *                                   std_encoding_consts.HORIZONTAL, 
  73.    *                                   std_encoding_consts.VERTICAL, and/or 
  74.    *                                   std_encoding_consts.NOT_ORIENTED).
  75.    */
  76.   public std_constraint(int encode_val, int orient)
  77.     {
  78.       _encoding = encode_val;
  79.       _orientation = orient;
  80.       _impl = std_constraint_impl.the_impl();
  81.     }
  82.  
  83.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  84.  
  85.   /** Create a human readable string describing the constraint. */
  86.   public String toString()
  87.     {
  88.       if (impl() == null) return "NULL CONSTRAINT IMPL";
  89.  
  90.       return impl().str_for(encoding(), orientation());
  91.     }
  92.  
  93.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  94.  
  95.   /** Create a terse human readable string describing the constraint. */
  96.   public String tag()
  97.     {
  98.       if (impl() == null) return "0IMP!";
  99.  
  100.       return impl().tag_for(encoding(), orientation());
  101.     }
  102.  
  103.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  104.  
  105.   /** Indicate if this constraint is actually encoding for no constraint. */
  106.   public boolean is_none()
  107.     {
  108.       if (impl() == null) return true;
  109.       return impl().is_none(encoding());
  110.     }
  111.  
  112.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  113.  
  114.   /** Indicate if this constraint is encoding for an external constraint. */
  115.   public boolean is_external()
  116.     {
  117.       if (impl() == null) return true;
  118.       return impl().is_external(encoding());
  119.     }
  120.  
  121.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  122. }
  123. /*=========================== COPYRIGHT NOTICE ===========================
  124.  
  125. This file is part of the subArctic user interface toolkit.
  126.  
  127. Copyright (c) 1996 Scott Hudson and Ian Smith
  128. All rights reserved.
  129.  
  130. The subArctic system is freely available for most uses under the terms
  131. and conditions described in 
  132.   http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html 
  133. and appearing in full in the lib/interactor.java source file.
  134.  
  135. The current release and additional information about this software can be 
  136. found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
  137.  
  138. ========================================================================*/
  139.